<?php
namespace app\index\controller;
use think\Controller;
use think\Db;
use \think\View;
class Index extends Controller
{
    public function index()
    {
        return  $this->fetch('list');
    }

    public function  buylist(){
        return  $this->fetch('buylist');
    }



    public function  updateimages(){
        $file = request()->file('image');
        if ($file == null) {
            return msg(2, '缺少主要参数', $file);
            exit();
        }
        $public = "./public/uploads/";
        $info = $file->validate(['size'=>156780,'ext'=>'jpg,png,gif,bmp'])->move(ROOT_PATH . 'public' . DS . 'uploads');
        if($info){
            // 成功上传后 获取上传信息
            //echo $info->getExtension();
            $url =   $info->getSaveName();
            return msg(1, '返还图片路径', $public.$url);
            //echo $info->getFilename();
        }else{
            // 上传失败获取错误信息
            $msg = $file->getError();
            return msg(2, '上次错误信息', $msg);
        }
    }



}
